package com.qa.dom.config.shiro;


import org.springframework.stereotype.Service;


/**
 * 热加载链接权限
 * @author 作者: z77z
 * @date 创建时间：2017年2月15日 下午4:16:07
 */
@Service
public class ShiroService {
	
/*	@Autowired
	ShiroFilterFactoryBean shiroFilterFactoryBean;
	

	
	*//**
	 * 初始化权限
	 *//*
	public Map<String, String> loadFilterChainDefinitions() {
		// 权限控制map.从数据库获取
		Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();



		// 过滤链
		filterChainDefinitionMap.put("/css/**", "anon");
		filterChainDefinitionMap.put("/fonts/**", "anon");
		filterChainDefinitionMap.put("/images/**", "anon");
		filterChainDefinitionMap.put("/js/**", "anon");
		filterChainDefinitionMap.put("/plugins/**", "anon");
		filterChainDefinitionMap.put("/500.html", "perms");
		filterChainDefinitionMap.put("/favicon.ico", "anon");
		filterChainDefinitionMap.put("/mylogin", "anon");

*//*        filterChainDefinitionMap.put("/register.html", "anon"); // 注册界面
        filterChainDefinitionMap.put("/register", "anon"); // 注册提交数据
        filterChainDefinitionMap.put("/sencCode", "anon"); // 发送邮箱验证码
        filterChainDefinitionMap.put("/isUsername/**", "anon"); // 判断用户名是否存在
        filterChainDefinitionMap.put("/isEmail/**", "anon"); // 判断邮箱是否存在*//*

		//正式
		filterChainDefinitionMap.put("/**", "authc");
		return filterChainDefinitionMap;
	}

	*//**
	 * 重新加载权限
	 *//*
	public void updatePermission() {

		synchronized (shiroFilterFactoryBean) {

			AbstractShiroFilter shiroFilter = null;
			try {
				shiroFilter = (AbstractShiroFilter) shiroFilterFactoryBean
						.getObject();
			} catch (Exception e) {
				throw new RuntimeException(
						"get ShiroFilter from shiroFilterFactoryBean error!");
			}

			PathMatchingFilterChainResolver filterChainResolver = (PathMatchingFilterChainResolver) shiroFilter
					.getFilterChainResolver();
			DefaultFilterChainManager manager = (DefaultFilterChainManager) filterChainResolver
					.getFilterChainManager();

			// 清空老的权限控制
			manager.getFilterChains().clear();

			shiroFilterFactoryBean.getFilterChainDefinitionMap().clear();
			shiroFilterFactoryBean
					.setFilterChainDefinitionMap(loadFilterChainDefinitions());
			// 重新构建生成
			Map<String, String> chains = shiroFilterFactoryBean
					.getFilterChainDefinitionMap();
			for (Map.Entry<String, String> entry : chains.entrySet()) {
				String url = entry.getKey();
				String chainDefinition = entry.getValue().trim()
						.replace(" ", "");
				manager.createChain(url, chainDefinition);
			}

			System.out.println("更新权限成功！！");
		}
	}*/
}
